﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>@ViewBag.Title</title>
    <link rel="shortcut icon" href="~/img/favicon.ico" /> 
    @Styles.Render("~/Content/css")
    @Scripts.Render("~/bundles/modernizr")
    @Styles.Render("~/Content/kendo")
    @Scripts.Render("~/bundles/jquery")
    @Scripts.Render("~/bundles/unobtrusive")
    @Scripts.Render("~/bundles/kendo")
</head>
<body>
    <div class="navbar navbar-fixed-top">
        <div class="navbar-inner">
            <div class="container">
                <button type="button" class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                </button>
                @Html.ActionLink("Medusa's Ebay", "Index", "Home", null, new { @class = "brand" })

                @if (User.IsInRole("Admin"))
                {
                    @Html.ActionLink("Admin", "Index", "Admin/AdminHome", null, new { @class = "brand" })
                }
                <div class="nav-collapse collapse">
                    <ul class="nav">
                        @if (User.Identity.IsAuthenticated)
                        {
                          <li class="dropdown">
                                <a href="#" class="dropdown-toggle" data-toggle="dropdown">
                                    Summary
                                    <b class="caret"></b>
                                </a>
                                <ul class="dropdown-menu">
                                        <li>
                                            <a href="~/Delivery/ByUser">Deliveries</a>
                                        </li>
                                            <li>
                                            <a href="~/Auctions/ByUser">Auctions</a>
                                        </li>
                                            <li>
                                            <a href="~/Funds/ByUser">Withdraws</a>
                                        </li>
                                </ul>
                          </li>
                        }

                        <li class="dropdown">
                            <a href="#" class="dropdown-toggle" data-toggle="dropdown">
                                Products
                                <b class="caret"></b>
                            </a>
                            <ul class="dropdown-menu">
                                <li><a href="~/Products/All">All Products</a></li>

                                @if (User.Identity.IsAuthenticated)
                                {
                                    <li>@Html.ActionLink("My products", "ByUser", "Products", null, null)</li>
                                    <li>@Html.ActionLink("Sell products", "Create", "Auctions",null, null)</li>
                                     <li><a href="~/Products/Create">Add Product</a></li>
                                }
                            </ul>

                            
                        </li>

                        <li>
                            @if (User.Identity.IsAuthenticated) {
                                @Html.ActionLink("My cart", "ByUser", "ShoppingCart", null, null);
                            }
                        </li>

                        <li>
                            @using (Html.BeginForm("Search", "Products", FormMethod.Get))
                            {
                                @(Html.Kendo().AutoComplete()
                                .Name("product")
                                .DataTextField("Title")
                                .MinLength(3)
                                .HtmlAttributes(new { style = "width:250px" })
                                .Placeholder("Search product")
                                .DataSource(source =>
                                {
                                    source.Read(read =>
                                    {
                                        read.Action("GetProducts", "Products")
                                            .Data("onAdditionalData");
                                    })
                                    .ServerFiltering(true);
                                })
                                )

                                <button id="btn-search" class="btn btn-success" type="submit">
                                    <i class="icon-search"></i>
                                    Search
                                </button>
                            }
                        </li>
                    </ul>

                    @Html.Partial("_LoginPartial")
                </div>
            </div>
        </div>
    </div>
    <div class="container">
        @RenderBody()
        <hr />
        <footer>
            <p>&copy; Medusa's Ebay</p>
        </footer>
    </div>

    @Scripts.Render("~/bundles/bootstrap")
    @RenderSection("scripts", required: false)

    @Scripts.Render("~/bungles/slidetop")

    <script>
        function onAdditionalData() {
            return {
                text: $("#product").val()
            };
        }

        $(document).ready(function () {
            $("#nav-menu").kendoMenu();
        });
    </script>
</body>
</html>
